using System;
using Castle.ActiveRecord;
using Castle.Components.Validator; 
using NHibernate.Expression;

namespace DecisionesInteligentes.iEvalua.Models
{
	[ActiveRecord]
	public class Application: ActiveRecordValidationBase<Application>
	{
		[PrimaryKey]
		public int Id { set; get; }
		
		[Property]
		[ValidateNonEmpty("Name cannot be empty")]
		public string Name { set; get; }
		
		public static Application FindByName(string name)
		{
			return Application.FindOne(new ICriterion[]
				{ 
					new EqExpression("Name", name) 
				}
			);
		}
	}
}